package com.ev.hr.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.ev.hr.dao.AfterExperienceDao;
import com.ev.hr.domain.AfterExperienceDO;
import com.ev.hr.service.AfterExperienceService;
import com.ev.hr.vo.AfterExperiencePageParam;
import com.ev.framework.utils.R;
import com.ev.apis.model.DsResultResponse;
import com.google.common.collect.Maps;


@Service
public class AfterExperienceServiceImpl implements AfterExperienceService {
	@Autowired
	private AfterExperienceDao afterExperienceDao;
	
	@Override
	public AfterExperienceDO get(String id){
		return afterExperienceDao.get(id);
	}
	
	@Override
	public List<AfterExperienceDO> list(Map<String, Object> map){
		return afterExperienceDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return afterExperienceDao.count(map);
	}
	
	@Override
	public int save(AfterExperienceDO afterExperience){
		return afterExperienceDao.save(afterExperience);
	}
	
	@Override
	public int update(AfterExperienceDO afterExperience){
		return afterExperienceDao.update(afterExperience);
	}

	@Override
	public int updateAll(AfterExperienceDO afterExperience){
		return afterExperienceDao.updateAll(afterExperience);
	}
	
	@Override
	public int remove(String id){
		return afterExperienceDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return afterExperienceDao.batchRemove(ids);
	}

	@Override
	public R saveAndVerify(AfterExperienceDO saveParam){
		if(saveParam.getId()!=null){
			return afterExperienceDao.update(saveParam)>0?R.ok():R.error();
		}
		return afterExperienceDao.save(saveParam)>0?R.ok():R.error();
	}

	@Override
	public Map<String, Object> getById(String id) {
		AfterExperienceDO afterExperience = afterExperienceDao.get(id);
		if (afterExperience != null) {
			Map<String,Object> result = Maps.newHashMap();
			result.put("data",afterExperience);
			return R.ok(result);
		}
		return R.error();
	}

	@Override
	public Map<String, Object> pageList(AfterExperiencePageParam pageParam) {
		Map<String,Object> result = Maps.newHashMap();
		List<Map<String, Object>> data = afterExperienceDao.pageList(pageParam);
		int total = afterExperienceDao.pageCount(pageParam);
		result.put("data", new DsResultResponse(pageParam.getPageno(),pageParam.getPagesize(),total,data));
		return R.ok(result);
	}

}
